home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / etc / rsconvert / main.c < prev    next >
C/C++ Source or Header  |  1994-08-09  |  2KB  |  101 lines

  1. /*
  2.  * main.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * main.c,v 4.1 1994/08/09 07:53:31 explorer Exp
  17.  *
  18.  * main.c,v
  19.  * Revision 4.1  1994/08/09  07:53:31  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:51:56  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0.1.1  91/11/26  21:11:33  cek
  26.  * patch3: Define ENDCAPS for cylinder-capping.
  27.  * 
  28.  * Revision 4.0  91/07/17  14:29:30  kolb
  29.  * Initial version.
  30.  * 
  31.  */
  32. #include <stdio.h>
  33. #ifdef SYSV
  34. #include <memory.h>
  35. #endif
  36. #include "libcommon/common.h"
  37.  
  38. extern FILE *yyin;
  39.  
  40. #define usage(v)        fprintf(stderr,"usage: %s [oldfile]\n",v)
  41.  
  42. main(argc, argv)
  43. int argc;
  44. char **argv;
  45. {
  46.     if (argc > 2) {
  47.         usage(argv[0]);
  48.         exit(1);
  49.     }
  50.  
  51.     if (argc == 2) {
  52.         yyin = fopen(argv[1], "r");
  53.         if (yyin == (FILE *)NULL) {
  54.             fprintf(stderr,"Cannot open %s\n",argv[1]);
  55.             exit(2);
  56.         }
  57.     } else
  58.         yyin = stdin;
  59.     printf("/* Converted by rsconvert */\n");
  60.     printf("#define ENDCAPS\n");
  61.     yyparse();
  62. }    
  63.  
  64. char *
  65. strsave(s)
  66. char *s;
  67. {
  68.     extern voidstar Malloc();
  69.     char *r;
  70.  
  71.     r = (char *)Malloc(strlen(s) + 1);
  72.     strcpy(r, s);
  73.     return r;
  74. }
  75.  
  76. voidstar
  77. Malloc(n)
  78. unsigned n;
  79. {
  80.     voidstar r;
  81.     extern voidstar malloc();
  82.  
  83.     r = malloc(n);
  84.     if (r == (voidstar)NULL) {
  85.         fprintf(stderr,"Out of memory allocating %d bytes.\n");
  86.         exit(1);
  87.     }
  88.     return r;
  89. }
  90.  
  91. voidstar
  92. Calloc(nelem, elen)
  93. unsigned nelem, elen;
  94. {
  95.     voidstar res;
  96.  
  97.     res = Malloc(nelem*elen);
  98.     bzero(res, (int)nelem*elen);
  99.     return res;
  100. }
  101.